package com.zsy.dao;

import com.zsy.dto.DishDto;
import com.zsy.pojo.Dish;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DishDao {

    @Select("select count(*) from dish where category_id=#{categoryId}")
    long findById(long id);

    @Insert("Insert into dish values(null,#{name},#{categoryId},#{price},#{code},#{image},#{description},#{status},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser},0);")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void save(DishDto dishDto);


    List<Dish> findByName(String name);

    @Select("select * from dish where id=#{id}")
    Dish findId(Long id);

    @Options(useGeneratedKeys = true ,keyColumn = "id",keyProperty = "id")
    void updateById(DishDto dishDto);

    @Select("Select * from dish where category_id=#{categoryId} and status=1")
    @Options(useGeneratedKeys = true ,keyProperty = "id" ,keyColumn = "id")
    List<Dish> dishList(@Param("categoryId") Long categoryId,@Param("status") Integer status);



    void updateStatus(@Param("status") Integer status, @Param("ids") List<Long> ids);

    void delete(@Param("ids") List<Long> ids);

    Integer findByIds(@Param("ids") List<Long> ids);
}
